package com.xuwei.ext.design_pattern.chainOfResponsibility;

public abstract class AbstractLogger {

	public static int INFO;
	public static int DEBUG;
	public static int ERROR;
	
	protected int level;
	
	//责任链的下一个元素
	protected AbstractLogger nextLogger;

	public void setNextLogger(AbstractLogger nextLogger) {
		this.nextLogger = nextLogger;
	}
	
	public void logMessage(int level, String message){
		if(this.level <= level){
			write(message);
		}
		if(nextLogger !=null){
			nextLogger.logMessage(level, message);
		}
	}
	
	abstract protected void write(String message);
}
